const Mock = require('mockjs');

// mock/categoryData.js
const categoryData = {
  // 一级分类：3~5 条
  category1List: [
    { id: 1, name: '手机数码' },
    { id: 2, name: '家用电器' },
    { id: 3, name: '电脑办公' },
    { id: 4, name: '服饰鞋包' },
    { id: 5, name: '图书音像' },
  ],

  // 二级分类：每个一级分类对应 3~5 个二级分类
  category2Map: {
    1: [
      // 手机数码 → 二级
      { id: 11, name: '智能手机' },
      { id: 12, name: '平板电脑' },
      { id: 13, name: '智能穿戴' },
      { id: 14, name: '手机配件' },
    ],
    2: [
      // 家用电器 → 二级
      { id: 21, name: '大家电' },
      { id: 22, name: '厨卫电器' },
      { id: 23, name: '生活电器' },
    ],
    3: [
      // 电脑办公 → 二级
      { id: 31, name: '笔记本电脑' },
      { id: 32, name: '台式机' },
      { id: 33, name: '电脑配件' },
      { id: 34, name: '办公设备' },
    ],
    4: [
      // 服饰鞋包 → 二级
      { id: 41, name: '男装' },
      { id: 42, name: '女装' },
      { id: 43, name: '鞋靴' },
      { id: 44, name: '箱包' },
    ],
    5: [
      // 图书音像 → 二级
      { id: 51, name: '小说文学' },
      { id: 52, name: '人文社科' },
      { id: 53, name: '科技图书' },
    ],
  },

  // 三级分类：每个二级分类对应 3~5 个三级分类
  category3Map: {
    11: [
      // 智能手机 → 三级
      { id: 111, name: '安卓手机' },
      { id: 112, name: '苹果手机' },
      { id: 113, name: '游戏手机' },
    ],
    12: [
      // 平板电脑 → 三级
      { id: 121, name: 'iPad' },
      { id: 122, name: '安卓平板' },
      { id: 123, name: '二合一设备' },
    ],
    13: [
      // 智能穿戴 → 三级
      { id: 131, name: '智能手表' },
      { id: 132, name: '智能手环' },
      { id: 133, name: 'TWS耳机' },
    ],
    21: [
      // 大家电 → 三级
      { id: 211, name: '电视' },
      { id: 212, name: '冰箱' },
      { id: 213, name: '洗衣机' },
      { id: 214, name: '空调' },
    ],
    22: [
      // 厨卫电器 → 三级
      { id: 221, name: '油烟机' },
      { id: 222, name: '燃气灶' },
      { id: 223, name: '热水器' },
    ],
    31: [
      // 笔记本电脑 → 三级
      { id: 311, name: '轻薄本' },
      { id: 312, name: '游戏本' },
      { id: 313, name: '商务本' },
    ],
    32: [
      // 台式机 → 三级
      { id: 321, name: '游戏主机' },
      { id: 322, name: '迷你主机' },
    ],
    41: [
      // 男装 → 三级
      { id: 411, name: 'T恤' },
      { id: 412, name: '衬衫' },
      { id: 413, name: '外套' },
    ],
    42: [
      // 女装 → 三级
      { id: 421, name: '连衣裙' },
      { id: 422, name: '上衣' },
      { id: 423, name: '裤子' },
    ],
    51: [
      // 小说文学 → 三级
      { id: 511, name: '网络小说' },
      { id: 512, name: '经典文学' },
      { id: 513, name: '青春文学' },
    ],
    // 其他可自行扩展
  },
};

module.exports = [
  {
    url: '/admin/product/category1/list',
    type: 'get',
    response: () => {
      return {
        code: 200,
        message: 'success',
        data: categoryData.category1List || [],
      };
    },
  },
  {
    url: '/admin/product/category2/list',
    type: 'get',
    response: (config) => {
      const url = config.url;
      const match = url.match(/\/admin\/product\/category2\/list\/(\d+)/);
      const categoryId = parseInt(match[1]);
      return {
        code: 200,
        message: 'success',
        data: categoryData.category2Map[categoryId] || [],
      };
    },
  },
  {
    url: '/admin/product/category3/list',
    type: 'get',
    response: (config) => {
      const url = config.url;
      const match = url.match(/\/admin\/product\/category3\/list\/(\d+)/);
      const categoryId = parseInt(match[1]);
      return {
        code: 200,
        message: 'success',
        data: categoryData.category3Map[categoryId] || [],
      };
    },
  },
  {
    url: '/admin/product/attrInfoList',
    type: 'get',
    response: (config) => {
      return {
        code: 200,
        message: 'success',
        data: [
          {
            attrId: 1,
            attrName: '屏幕尺寸',
            categoryId: 61,
            categoryLevel: 3,
            attrValueList: [
              {
                id: 1,
                valueName: '5.5英寸',
                attrId: 1,
              },
              {
                id: 2,
                valueName: '6.1英寸',
                attrId: 1,
              },
              {
                id: 3,
                valueName: '6.7英寸',
                attrId: 1,
              },
            ],
          },
          {
            attrId: 2,
            attrName: '分辨率',
            categoryId: 61,
            categoryLevel: 3,
            attrValueList: [
              {
                id: 4,
                valueName: '1080P',
                attrId: 2,
              },
              {
                id: 5,
                valueName: '2K',
                attrId: 2,
              },
              {
                id: 6,
                valueName: '4K',
                attrId: 2,
              },
            ],
          },
          {
            attrId: 3,
            attrName: '颜色',
            categoryId: 61,
            categoryLevel: 3,
            attrValueList: [
              {
                id: 7,
                valueName: '黑色',
                attrId: 3,
              },
              {
                id: 8,
                valueName: '白色',
                attrId: 3,
              },
              {
                id: 9,
                valueName: '金色',
                attrId: 3,
              },
              {
                id: 10,
                valueName: '蓝色',
                attrId: 3,
              },
            ],
          },
          {
            attrId: 4,
            attrName: '内存',
            categoryId: 61,
            categoryLevel: 3,
            attrValueList: [
              {
                id: 11,
                valueName: '64GB',
                attrId: 4,
              },
              {
                id: 12,
                valueName: '128GB',
                attrId: 4,
              },
              {
                id: 13,
                valueName: '256GB',
                attrId: 4,
              },
              {
                id: 14,
                valueName: '512GB',
                attrId: 4,
              },
            ],
          },
          {
            attrId: 5,
            attrName: '网络',
            categoryId: 61,
            categoryLevel: 3,
            attrValueList: [
              {
                id: 15,
                valueName: '4G',
                attrId: 5,
              },
              {
                id: 16,
                valueName: '5G',
                attrId: 5,
              },
            ],
          },
          {
            attrId: 6,
            attrName: '品牌',
            categoryId: 61,
            categoryLevel: 3,
            attrValueList: [
              {
                id: 17,
                valueName: '苹果',
                attrId: 6,
              },
              {
                id: 18,
                valueName: '华为',
                attrId: 6,
              },
              {
                id: 19,
                valueName: '小米',
                attrId: 6,
              },
              {
                id: 20,
                valueName: '三星',
                attrId: 6,
              },
            ],
          },
        ],
      };
    },
  },
  {
    url: '/admin/product/saveAttrInfo',
    type: 'post',
    response: (config) => {
      return {
        code: 200,
        message: 'success',
        data: 'ok',
      };
    },
  },
];
